package com.example.mapper;

import com.example.pojo.Appointment;
import com.example.pojo.Appointment;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface AppointmentMapper {

    List<Appointment> selectAll(@Param("userId")Integer userId,@Param("ownerId") Integer ownerId,@Param("role") String role);

    @Select("select * from appointment where id = #{id}")
    Appointment selectById(Integer id);

    void add(Appointment appointment);

    @Delete("delete from appointment where user_id = #{userId} and room_id=#{roomId}")
    void deleteById(@Param("userId") Integer userId,@Param("roomId") Integer roomId);

    //查询是否重复预约
    int existsByUserAndRoom(@Param("userId") Integer userId,@Param("roomId") Integer roomId,
                                @Param("startTime")String startTime, @Param("endTime") String endTime);

   void cancelAppointment(Appointment appointment);

    List<Appointment> selectAllByTimeAndStatus(@Param("time") String time,@Param("status") Integer status);

    /**
     * 更新预约状态
     * @param appointment
     * @return
     */
   int updateStatus(Appointment appointment);

    int unProcessedCount(Integer ownerId);

    // 统计待处理的预约数量
    int countPendingAppointments(Integer ownerId);

    // 统计今日新增的预约数量
    int countTodayNewAppointments(@Param("ownerId") Integer ownerId,@Param("today") LocalDate today);
}
